import pymysql.cursors

# 连接参数
connection = pymysql.connect(host='127.0.0.1:3306',
                             user='root',
                             password='111111',
                             database='2023',
                             cursorclass=pymysql.cursors.DictCursor)

try:
    # 创建游标对象
    with connection.cursor() as cursor:
        # 执行查询
        sql = "SELECT * FROM your_table"
        cursor.execute(sql)
        # 获取所有记录列表
        results = cursor.fetchall()
        for row in results:
            print(row)
finally:
    # 关闭连接
    connection.close()